package com.jxufe;

import java.util.Scanner;

public class pingweidafen {
    public static void main(String[] args) {
        Scanner scanner =new Scanner(System.in);
        System.out.println("请给六位选手打分:");
        int []arrs=new int[6];
        for (int i = 0; i < arrs.length; i++) {
            arrs[i]=scanner.nextInt();
        }
        int[]arr1=new int[4];
        int max=max(arrs);
        int min=min(arrs);
        for (int i = 0; i < arrs.length; i++) {
            int temp=0;
            if (arrs[i]==max){
                temp=arrs[i];
                arrs[i]=arrs[4];
                arrs[4]=arrs[i];

            }else if (arrs[i]==min){
                temp=arrs[i];
                arrs[i]=arrs[4];
                arrs[4]=arrs[i];
            }
        }
        for (int i = 0; i < arrs.length-2; i++) {
            arr1[i]=arrs[i];
        }
        for (int i = 0; i < arr1.length; i++) {
            System.out.println(arr1[i]);
        }
        double aver = aver(arr1);
        System.out.println(aver);
    }

    /**
     * 求最大值函数
     * @param arrs
     * @return
     */
    public static int max(int []arrs){
        int max=arrs[0];
        for (int i = 1; i < arrs.length; i++) {
            if (arrs[i]>max){
                max=arrs[i];
            }
        }
        System.out.println(max);
        return max;
    }

    /**
     * 求最小值函数
     * @param arrs
     * @return
     */
    public static int min(int []arrs){
        int min=arrs[0];
        for (int i = 1; i < arrs.length; i++) {
            if (arrs[i]<min){
                min=arrs[i];
            }
        }
        System.out.println(min);
        return min;
    }
    /**
     * 求平均值的函数
     */
    public static double aver(int[]arrs){
        double sum=0;
        for (int i = 0; i < arrs.length; i++) {
            sum+=arrs[i];
        }
        return sum/arrs.length;
    }
}
